import Blockly from 'blockly/core'
import 'blockly/python_compressed'
import 'blockly/blockly_compressed'
import 'blockly/blocks_compressed'

Blockly.Blocks.two_sum_function = {
  init: function () {
    this.appendValueInput('firstParameter').setCheck(null).appendField('sum')
    this.appendValueInput('secondParameter').setCheck(null).appendField(',')
    this.setInputsInline(true)
    this.setOutput(true, Number)
    this.setColour(230)
    this.setTooltip('')
    this.setHelpUrl('')
  }
}

Blockly.Python.two_sum_function = function (block) {
  const firstCode = Blockly.Python.valueToCode(
    block,
    'firstParameter',
    Blockly.Python.ORDER_NONE
  )
  const secondCode = Blockly.Python.valueToCode(
    block,
    'secondParameter',
    Blockly.Python.ORDER_NONE
  )
  const code = 'sum(' + firstCode + ',' + secondCode + ')'
  return [code, Blockly.Python.ORDER_NONE]
}

Blockly.Blocks.single_sum_function = {
  init: function () {
    this.appendValueInput('singleParameter').setCheck(null).appendField('sum')
    this.setInputsInline(true)
    this.setOutput(true, Number)
    this.setColour(230)
    this.setTooltip('')
    this.setHelpUrl('')
  }
}

Blockly.Python.single_sum_function = function (block) {
  const singleCode = Blockly.Python.valueToCode(
    block,
    'singleParameter',
    Blockly.Python.ORDER_NONE
  )
  const code = 'sum(' + singleCode + ')'
  return [code, Blockly.Python.ORDER_NONE]
}

export default Blockly
